package com.igeek.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.util.List;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * <p>
 * 
 * </p>
 *
 * @author spike
 * @since 2022-01-12
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Document(indexName = "product",shards = 3,replicas = 0)
public class Product implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String name;
    @Field(type = FieldType.Text,analyzer = "ik_smart")
    @TableField("subTitle")
    private String subTitle;
    @Field(type = FieldType.Double)
    @TableField("originalPrice")
    private Float originalPrice;
    @Field(type = FieldType.Double)
    @TableField("promotePrice")
    private Float promotePrice;
    @Field(type = FieldType.Integer)
    private Integer stock;
    @Field(type = FieldType.Integer)
    private Integer cid;
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "uuuu-MM-dd'T'HH:mm:ss.SSSX")
    @TableField("createDate")
    private LocalDateTime createdate;

    //这个属性在数据表中没有对应字段，需要排除
    @TableField(exist = false)
    private Category category;
    /*firstProductImage这个属性，是从productSingleImages集合中取出第一个来，用于显示这个产品的默认图片。*/
    @TableField(exist = false)
    private Productimage firstProductImage;


    /*缩略图*/
    @TableField(exist = false)
    private List<Productimage> productSingleImages;
    /*详情图*/
    @TableField(exist = false)
    private List<Productimage> productDetailImages;
    /*累计评价*/
    @TableField(exist = false)
    private Integer reviewCount;
    /*评价*/
    @TableField(exist = false)
    private List<Review> reviews;

    @TableField(exist = false)
    private List<Propertyvalue> pvs;
    /*销量*/
    @TableField(exist = false)
    private Integer saleCount;


}
